package com.heer.gymnasium.module.store.beans;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.heer.gymnasium.base.BaseBean;
import com.heer.gymnasium.module.coach.beans.CoachResponseBean;
import com.heer.gymnasium.module.common.beans.GlobeBean;
import com.heer.gymnasium.module.main.beans.CategoryBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yan on 2018/1/16.
 * 体育馆列表item实体类
 */

public class StoreBean extends BaseBean implements Serializable {
    private String sid;
    private String stadiumname;
    private String stadiumaddress;
    private String stadiumpic;
    private String la;
    private String lo;
    private List<GlobeBean.Tag> tag_list;
    private List<String> category;
    private String eval;
    private String distance;
    private String is_buy;

    private String stadiumcontent;
    private String stadiumtel;
    private String focus_id;
    private List<GlobeBean.Tag> server;
    private String stadiumbusinesstime;
    private String stadiumspecialtime;
    private List<CategoryBean> planList;


    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getStadiumname() {
        return stadiumname;
    }

    public void setStadiumname(String stadiumname) {
        this.stadiumname = stadiumname;
    }

    public String getStadiumaddress() {
        return stadiumaddress;
    }

    public void setStadiumaddress(String stadiumaddress) {
        this.stadiumaddress = stadiumaddress;
    }

    public String getStadiumpic() {
        return stadiumpic;
    }

    public void setStadiumpic(String stadiumpic) {
        this.stadiumpic = stadiumpic;
    }

    public String getLa() {
        return la;
    }

    public void setLa(String la) {
        this.la = la;
    }

    public String getLo() {
        return lo;
    }

    public void setLo(String lo) {
        this.lo = lo;
    }

    public List<GlobeBean.Tag> getTag_list() {
        return tag_list;
    }

    public void setTag_list(List<GlobeBean.Tag> tag_list) {
        this.tag_list = tag_list;
    }

    public List<String> getCategory() {
        return category;
    }

    public void setCategory(List<String> category) {
        this.category = category;
    }

    public String getEval() {
        return eval;
    }

    public void setEval(String eval) {
        this.eval = eval;
    }

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public String getIs_buy() {
        return is_buy;
    }

    public void setIs_buy(String is_buy) {
        this.is_buy = is_buy;
    }

    public String getStadiumcontent() {
        return stadiumcontent;
    }

    public void setStadiumcontent(String stadiumcontent) {
        this.stadiumcontent = stadiumcontent;
    }

    public String getStadiumtel() {
        return stadiumtel;
    }

    public void setStadiumtel(String stadiumtel) {
        this.stadiumtel = stadiumtel;
    }

    public String getFocus_id() {
        return focus_id;
    }

    public void setFocus_id(String focus_id) {
        this.focus_id = focus_id;
    }

    public List<GlobeBean.Tag> getServer() {
        return server;
    }

    public void setServer(List<GlobeBean.Tag> server) {
        this.server = server;
    }

    public String getStadiumbusinesstime() {
        return stadiumbusinesstime;
    }

    public void setStadiumbusinesstime(String stadiumbusinesstime) {
        this.stadiumbusinesstime = stadiumbusinesstime;
    }

    public String getStadiumspecialtime() {
        return stadiumspecialtime;
    }

    public void setStadiumspecialtime(String stadiumspecialtime) {
        this.stadiumspecialtime = stadiumspecialtime;
    }

    public List<CategoryBean> getPlanList() {
        return planList;
    }

    public void setPlanList(List<CategoryBean> planList) {
        this.planList = planList;
    }

    //    数据转换
    public static List<StoreBean> dataChange(List<StoreResponseBean.Item> data) {
        List<StoreBean> beanList = new ArrayList<>();

        if (data != null) {
            for (int storeIndex = 0; storeIndex < data.size(); storeIndex++) {
                StoreBean bean = new StoreBean();
                StoreResponseBean.Item item = data.get(storeIndex);
                bean.setSid(item.getSid());
                bean.setStadiumname(item.getStadiumname());
                bean.setStadiumaddress(item.getStadiumaddress());
                bean.setStadiumpic(item.getStadiumpic());
                bean.setLa(item.getLa());
                bean.setLo(item.getLo());
                if (item.getTag_list() != null) {
                    String[] arr = item.getTag_list().split(",");
                    ArrayList<GlobeBean.Tag> list = new ArrayList<>();
                    for (int tagIndex = 0; tagIndex < arr.length; tagIndex++) {
                        GlobeBean.Tag tag = new GlobeBean.Tag();
                        tag.setName(arr[tagIndex]);
                        list.add(tag);
                    }
                    bean.setTag_list(list);
                } else {
                    bean.setTag_list(new ArrayList<GlobeBean.Tag>());
                }

                if (item.getPlan_list() != null) {
                    ArrayList<CategoryBean> planArrayList = new ArrayList<>();
                    for (StoreResponseBean.Plan itemPlan : item.getPlan_list()) {
                        CategoryBean plan = new CategoryBean();
                        plan.setId(itemPlan.getCate_id());
                        plan.setTitle(itemPlan.getCate_name());
                        plan.setIcon(itemPlan.getIcon());
                        planArrayList.add(plan);
                    }
                    bean.setPlanList(planArrayList);
                } else {
                    bean.setPlanList(new ArrayList<CategoryBean>());
                }

                bean.setCategory(item.getCategory());
                bean.setEval(item.getEval());
                bean.setDistance(item.getDistance());
                bean.setIs_buy(item.getIs_buy());
                beanList.add(bean);
            }
        }
        return beanList;
    }

    @Override
    public String toString() {
        return "StoreBean{" +
                "sid='" + sid + '\'' +
                ", stadiumname='" + stadiumname + '\'' +
                ", stadiumaddress='" + stadiumaddress + '\'' +
                ", stadiumpic='" + stadiumpic + '\'' +
                ", la='" + la + '\'' +
                ", lo='" + lo + '\'' +
                ", tag_list='" + tag_list + '\'' +
                ", category=" + category +
                ", eval='" + eval + '\'' +
                ", distance='" + distance + '\'' +
                ", is_buy='" + is_buy + '\'' +
                '}';
    }

    public static StoreBean dataChange(CoachResponseBean.Item data) {
        StoreBean bean = new StoreBean();
        bean.setSid(data.getSid());
        bean.setStadiumname(data.getStadiumname());
        return bean;
    }

    public static StoreBean dataChange(StoreResponseBean.Info data) {
        StoreBean bean = new StoreBean();
        bean.setSid(data.getSid());
        bean.setStadiumname(data.getStadiumname());
        bean.setStadiumtel(data.getStadiumtel());
        bean.setStadiumcontent(data.getStadiumcontent());
        bean.setServer(data.getServer());
        bean.setTag_list(data.getTag_list());
        bean.setStadiumaddress(data.getStadiumaddress());
        bean.setStadiumbusinesstime(data.getStadiumbusinesstime());
        bean.setStadiumspecialtime(data.getStadiumspecialtime());
        bean.setLa(data.getLa());
        bean.setLo(data.getLo());
        bean.setEval(data.getEval());
        bean.setFocus_id(data.getFocus_id());
        return bean;
    }
}
